/* __auth__ : KunLin */

package com.cskaoyan.mapper;

import com.cskaoyan.bean.Goods;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

import java.util.List;

public interface GoodsElasticsearchMapper extends ElasticsearchRepository<Goods,Long> {

    Goods findByGoodsSn(String goodsSn);

    Goods findById(Integer id);

    Page<Goods> findByNameLike(String name, Pageable pageable);

//    @Query("{\"match\": {\"name\": \"?0\"}}")
//    @Query(" {\"fuzzy\": {\"name\": {\"value\": \"?0\",\"fuzziness\": 2}}},{\"match\": {\"content\": \"?0\"}}")
//    @Query(" {\"fuzzy\": {\"name\": {\"value\": \"?0\",\"fuzziness\": 2}}}")
    Page<Goods> findByName(String name, Pageable pageable);

    List<Goods> findByName(String name);


    List<Goods> findByNameLike(String name);

    List<Goods> findByKeywords(String Keyword);

    List<Goods> findByBrief(String Keyword);



    List<Goods> findGoodsByNameOrBriefOrKeywords(String k1,String k2, String k3);

    Goods findByGoodsSnAndIdAndNameLike(String goodsSn, Integer id, String name);

    Goods findByGoodsSnAndId(String goodsSn, Integer id);

    Goods findByGoodsSnAndNameLike(String goodsSn, String name);

    Goods findByIdAndNameLike(Integer id, String name);
}
